<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>客房管理</title>
    <link href="/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="/layui/css/layui.css"  media="all">
    <style type="text/css">
        /* 去除所有的页边距 */
        *{
            margin:0px;
            padding:0px;
        }
        /* 设置一个背景颜色 */
        body{
            background-color: #DFF0D8;
            /*background:url(img/greenBack.jpg);*/
        }
        /*#titletab{*/
        /*    background-color: #ffffff;*/
        /*}*/

        .bt{
            background-color: #287d6b;
        }

        /* .container{
            width: 100%;

        } */
    </style>

</head>

<body>
<div class = "container"  style="margin-top:10px;" >
    <!-- 顶部tab栏 -->
    <div class="row clearfix" id="titletab" >
        <div class="col-md-12 column">
            <ul class="layui-nav layui-bg-green" lay-filter="">
                <!--                    class="layui-this" 使得按钮处于选中-->
                <li class="layui-nav-item"><a href="/pages/首页.html">首页</a></li>
                <li class="layui-nav-item layui-this"><a href="">客房管理</a></li>
                <li class="layui-nav-item"><a href="/pages/会员管理.html">会员管理</a></li>
                <li class="layui-nav-item"><a href="/pages/商品管理.html">商品管理</a></li>
                <li class="layui-nav-item"><a href="/pages/员工管理.html">员工管理</a></li>
                <li class="layui-nav-item"><a href="/pages/系统日志.html">系统日志</a></li>
            </ul>
        </div>
    </div>


    <div class="row clearfix" style="width: 100%">
        <!--添加楼层按钮-->
        <!-- layui-anim layui-anim-scaleSpring-->
        <div class="col-md-12 column " >
                <div class="col-md-5"></div>
                <h3><span class="label label-primary  col-lg-2" style='margin-top:15px'  >楼层管理</span></h3>
                <div class="col-xs-4"></div>
                <button type="button" class="layui-btn layui-btn-radius layui-btn-sm "
                        style='margin-top:14px' onclick="showNewFloor_Modal()">添加楼层</button>
        </div>

        <!-- 楼层表头-->
        <div class="col-md-12 column ">
            <table class="layui-table table-hover table-condensed" lay-skin="line" lay-size="sm"
               style='text-align: center;margin-top:14px;background-color: #f7f7f7'>
            <thead>
            <tr>
                <td>楼层</td>
                <td>起始房间</td>
                <td>终止房间</td>
                <td>楼栋号</td>
                <td>操作</td>
            </tr>
            </thead>
            <tbody id="tbody">
            </tbody>
        </table>
        </div>

        <!--添加房间类型按钮-->
        <div class="col-md-12 column">
            <div class="col-md-5"></div>
            <h3><span class="label label-primary  col-lg-2" style='margin-top:8px'  >房型管理</span></h3>
            <div class="col-xs-4"></div>
            <button type="button"  class="layui-btn layui-btn-radius layui-btn-sm "
                    style='margin-top:7px' onclick="showNewRoomType_Modal()">添加房型</button>
        </div>

        <!-- 房间类型表头-->
        <div>
            <table class="layui-table table-hover table-condensed" lay-skin="line" lay-size="sm"
                   style='text-align: center;margin-top:0px;background-color: #f7f7f7'>
                <thead>
                <tr>
                    <td>房间类型</td>
                    <td>价格</td>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody id="tbody_type">
                </tbody>
            </table>
        </div>

        <!-- 添加房间按钮-->
        <div class="col-md-12 column" >
            <div class="col-md-5"></div>
            <h3><span class="label label-primary col-lg-2" style='margin-top:8px'>房间管理</span></h3>
            <div class="col-xs-4"></div>
            <button type="button" class="layui-btn layui-btn-radius layui-btn-sm "
                    style='margin-top:5px' onclick="showNewRoom_Modal()">添加房间</button>
        </div>

        <!-- 房间表头-->
        <div>
            <table class="layui-table  table-hover table-condensed" lay-skin="line" lay-size="sm"
                   style='text-align: center;margin-top:15px;background-color: #f7f7f7'>
                <thead>
                <tr>
                    <td>房号</td>
                    <td>房间类型</td>
                    <td>房间位置</td>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody id="tbody_room">
                </tbody>
            </table>
        </div>

    </div>

</div>

<!-- 新建楼层的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="newFloorModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">新建楼层</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="newFloor_id">
                <form class="form-horizontal">

                    <div class="input-group">
                        <span class="input-group-addon">楼层:</span>
                        <input type="text" name="no" id="newFloor_name" class="form-control"
                               placeholder="请输入楼层名称">
                    </div>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <div class="input-group">
                        <span class="input-group-addon">起始房号:</span>
<!--                        <label class="control-label col-md-3">起始房号:</label>-->
                        <input type="text" name="Start_name" id="newStart" class="form-control"
                               placeholder="请输入起始房号">
                    </div>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <div class="input-group">
                        <span class="input-group-addon">起始房号:</span>
                        <input type="text" name="end_name" id="newEnd" class="form-control"
                               placeholder="请输入终止房号">
                    </div>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <div class="input-group">
                        <span class="input-group-addon">楼栋号:</span>
                        <input type="text" name="building" id="newBuilding" class="form-control"
                               placeholder="请输入楼栋号">
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doNewFloor()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 删除楼层的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="delModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">删除提醒</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="del_id">
                <p id="del_msg"></p>
                <p>是否要删除该楼层？</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doDelete()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 修改楼层的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="editModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">修改楼层信息</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="edit_id">
                <form class="form-horizontal">
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">楼层:</label>
                        <div class="col-lg-8">
                            <input type="text" name="no" id="floor_name" class="form-control"
                                   placeholder="请输入楼层">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">起始房号:</label>
                        <div class="col-lg-8">
                            <input type="text" name="Start_name" id="start" class="form-control"
                                   placeholder="请输入起始房号">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">终止房号:</label>
                        <div class="col-lg-8">
                            <input type="text" name="end_name" id="end" class="form-control"
                                   placeholder="请输入终止房号">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">楼栋号:</label>
                        <div class="col-lg-8">
                            <input type="text" name="building" id="building" class="form-control"
                                   placeholder="请输入楼栋号">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doEdit()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 新建房间类型的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="newRoomTypeModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">新建房型</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="newRoomType_id">
                <form class="form-horizontal">

                    <div class="input-group">
                        <span class="input-group-addon">房型名称:</span>
<!--                        <label class="control-label col-md-3">房型名称:</label>-->
                        <input type="text" name="num" id="newRoomType" class="form-control"
                               placeholder="请输入房型名称">
                    </div>
                    &nbsp;&nbsp;&nbsp;&nbsp;

                    <div class="input-group">
                        <span class="input-group-addon">房型价格:</span>
                        <input type="text" name="type" id="newTypePrice" class="form-control"
                               placeholder="请输入房型价格">
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doNewRoomType()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 删除房间类型的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="delModal_roomType">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">删除提醒</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="delRoomType_id">
                <p id="delRoomType_msg"></p>
                <p>是否要删除该房间类型？</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doDelete_roomType()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 修改房间类型的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="editModal_roomType">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">修改房型信息</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="editRoomType_id">
                <form class="form-horizontal">
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">房型名称:</label>
                        <div class="col-lg-8">
                            <input type="text" name="type" id="edit_roomType" class="form-control"
                                   placeholder="请输入房型名称">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">房型价格:</label>
                        <div class="col-lg-8">
                            <input type="text" name="price" id="edit_typePrice" class="form-control"
                                   placeholder="请输入房间价格">
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doEdit_roomType()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 新建房间的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="newRoomModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">新建房间</h4>
            </div>

            <div class="modal-body">
                <input type="hidden" id="newRoom_id">
                <form class="form-horizontal">

                    <div class="input-group ">
                        <span class="input-group-addon">房号:</span>
<!--                        <label class="control-label col-md-3"></label>-->
                        <input type="text" name="num" id="newNum" class="form-control"
                               placeholder="请输入房号">
                    </div>
                    &nbsp;&nbsp;&nbsp;&nbsp;

                    <div class="input-group ">
                        <span class="input-group-addon">房间类型:</span>
<!--                        <label class="control-label col-md-3"></label>-->
<!--                            <input type="text" name="type" id="newType" class="form-control"-->
<!--                                   placeholder="请输入房间类型">-->
                        <div>
                        <select name = "choose"  id = "chooseType" class="form-control">
                        </select>
                        </div>
                    </div>

                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <div class="input-group ">
                        <span class="input-group-addon">所在区域:</span>
                        <input type="text" name="floor" id="newFloor" class="form-control"
                               placeholder="请输入所在区域">
                    </div>

                </form>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doNewRoom()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 删除房间的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="delModal_room">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">删除提醒</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="delRoom_id">
                <p id="delRoom_msg"></p>
                <p>是否要删除该房间？</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doDelete_room()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 修改房间的模态框 -->
<div class="modal fade" tabindex="-1" role="dialog" id="editModal_room">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">修改房间信息</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="editRoom_id">
                <form class="form-horizontal">
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">房号:</label>
                        <div class="col-lg-8">
                            <input type="text" name="num" id="room_num" class="form-control"
                                   placeholder="请输入房号">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">房间类型:</label>
                        <div class="col-lg-8">
                            <input type="text" name="type" id="room_type" class="form-control"
                                   placeholder="请输入房间类型">
                        </div>
                    </div>
                    <div class="form-group form-group-lg">
                        <label class="control-label col-md-3">所在区域:</label>
                        <div class="col-lg-8">
                            <input type="text" name="floor" id="room_floor" class="form-control"
                                   placeholder="请输入所在区域">
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="doEdit_room()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>

<script src="/jquery/jquery-3.4.1.js"></script>
<script src="/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="/layui/layui.js"></script>
<!--导航栏脚本-->
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function(){
        var element = layui.element;

        //…
    });
</script>

<script type="text/javascript">
    var oldType;
    jQuery(function(){
        //页面加载完毕，就去数据库中获取数据
        //          /allfloor 请求的地址
        jQuery.post("/all_floor",function(rst){//处理响应的结果
            var body="";
            for(var i=0;i<rst.length;i++)
            {
                var json=rst[i];//{"id":1,"floor_name":"A栋一层","start_room":'A101',"end_room":"A108","building"="A栋"}
                body+="<tr>";
                body+="<td>"+json.floor_name+"</td>";
                body+="<td>"+json.start_room+"</td>";
                body+="<td>"+json.end_room+"</td>";
                body+="<td>"+json.building+"</td>";
                body+="<td>";
                body+="<a href='#' onclick='showDelModal(\""+json.id+"\",\""+json.floor_name+"\")'>删除</a>&nbsp;&nbsp;";
                body+="<a href='#' onclick='showEditModal(" +
                    "\""+json.id+"\"," +
                    "\""+json.floor_name+"\"," +
                    "\""+json.start_room+"\"," +
                    "\""+json.end_room+"\"," +
                    "\""+json.building+"\")'>修改</a>";
                body+="</td>"
                body+="</tr>";

            }
            jQuery("#tbody").html(body);
        },"json");//表示返回数据的格式

        jQuery.post("/room_list",function(rst_room){//处理响应的结果
            var body1="";
            for(var j=0;j<rst_room.length;j++)
            {
                var json=rst_room[j];//{"id":1,"room_num":"A202","room_type":'普通单人房',"building":"A栋二层"}
                body1+="<tr>";
                body1+="<td>"+json.room_num+"</td>";
                body1+="<td>"+json.room_type+"</td>";
                body1+="<td>"+json.room_floor+"</td>";
                body1+="<td>";
                body1+="<a href='#' onclick='showDel_room(\""+json.id+"\",\""+json.room_num+"\")'>删除</a>&nbsp;&nbsp;";
                body1+="<a href='#' onclick='showEdit_room(" +
                    "\""+json.id+"\"," +
                    "\""+json.room_num+"\"," +
                    "\""+json.room_type+"\"," +
                    "\""+json.room_floor+"\")'>修改</a>";
                //body1+="</td>"
                body1+="</tr>";
            }
            jQuery("#tbody_room").html(body1);
        },"json");//表示返回数据的格式

        jQuery.post("/all_roomType",function(rst){//处理响应的结果
            var body="";
            for(var i=0;i<rst.length;i++)
            {
                var json=rst[i];//{"id":1,"floor_name":"A栋一层","start_room":'A101',"end_room":"A108","building"="A栋"}
                body+="<tr>";
                body+="<td>"+json.type+"</td>";
                body+="<td>"+json.type_price+"</td>";
                body+="<td>";
                body+="<a href='#' onclick='showDel_roomType(\""+json.id+"\",\""+json.type+"\")'>删除</a>&nbsp;&nbsp;";
                body+="<a href='#' onclick='showEdit_roomType(" +
                    "\""+json.id+"\"," +
                    "\""+json.type+"\"," +
                    "\""+json.type_price+"\")'>修改</a>";
                body+="</td>"
                body+="</tr>";

            }
            jQuery("#tbody_type").html(body);
        },"json");//表示返回数据的格式

        //在新建房间时，展示可选的房间类型
        jQuery.post("/all_roomType",function(rst){//处理响应的结果
            var body="";
            for(var i=0;i<rst.length;i++)
            {
                var json=rst[i];
                //<option value = "福建省">福建省</option>
                body+="<option value ='"+json.type+"'>"+json.type+"</option>";
            }
            jQuery("#chooseType").html(body);
        },"json");//表示返回数据的格式

    });

    function showEditModal(id,floor_name,start_room,end_room,building)
    {
        jQuery("#edit_id").val(id);
        jQuery("#floor_name").val(floor_name);
        jQuery("#start").val(start_room);
        jQuery("#end").val(end_room);
        jQuery("#building").val(building);
        jQuery("#editModal").modal("show");
    }

    function doEdit() {
        jQuery("#editModal").modal("hide");
        var id=jQuery("#edit_id").val();
        var name=jQuery("#floor_name").val();
        var start_name=jQuery("#start").val();
        var end_name=jQuery("#end").val();
        var building=jQuery("#building").val();
        jQuery.post("/edit_floor",{"id":id,"name":name,"start_name":start_name,"end_name":end_name,"building":building},function (rst) {
            alert(rst);
            if(rst=="修改成功")
            {
                location.reload();
            }
        })
    }

    function showDelModal(id,name)
    {
        jQuery("#del_id").val(id);
        jQuery("#del_msg").html(name);
        jQuery("#delModal").modal("show");
    }

    function doDelete(){
        jQuery("#delModal").modal("hide");
        var id = jQuery("#del_id").val();
        //json格式的属性名称必须和后台对应
        jQuery.post("/delete",{"id":id},function (rst) {
            alert(rst);
            //刷新页面,应重新加载一次
            if(rst=='删除成功')
            {
                //重新加载
                location.reload();
            }
        });
    }

    function showEdit_room(id,room_num,room_type,room_floor)
    {
        jQuery("#editRoom_id").val(id);
        jQuery("#room_num").val(room_num);
        jQuery("#room_type").val(room_type);
        jQuery("#room_floor").val(room_floor);
        jQuery("#editModal_room").modal("show");
    }

    function doEdit_room() {
        jQuery("#editModal_room").modal("hide");
        var id=jQuery("#editRoom_id").val();
        var num=jQuery("#room_num").val();
        var type=jQuery("#room_type").val();
        var floor=jQuery("#room_floor").val();
        jQuery.post("/edit_room",{"id":id,"num":num,"type":type,"floor":floor},function (rst) {
            alert(rst);
            if(rst=="修改成功")
            {
                location.reload();
            }
        })
    }

    function showDel_room(id,num)
    {
        jQuery("#delRoom_id").val(id);
        jQuery("#delRoom_msg").html(num);
        jQuery("#delModal_room").modal("show");
    }

    function doDelete_room(){
        jQuery("#delModal_room").modal("hide");
        var id = jQuery("#delRoom_id").val();
        //json格式的属性名称必须和后台对应
        jQuery.post("/deleteRoom",{"id":id},function (rst) {
            alert(rst);
            //刷新页面,应重新加载一次
            if(rst=='删除成功')
            {
                //重新加载
                location.reload();
            }
        });
    }

    function showNewFloor_Modal(){
        jQuery("#newFloor_id").val();
        jQuery("#newFloor_name").val();
        jQuery("#newStart").val();
        jQuery("#newEnd").val();
        jQuery("#newFloorModal").modal("show");
    }

    function doNewFloor() {
        jQuery("#newFloorModal").modal("hide");
        var id=jQuery("#newFloor_id").val();
        var name=jQuery("#newFloor_name").val();
        var start=jQuery("#newStart").val();
        var end=jQuery("#newEnd").val();
        var building=jQuery("#newBuilding").val();
        jQuery.post("/newFloor",{"id":id,"name":name,"start":start,"end":end,"building":building},function (rst){
            alert(rst);
            if(rst=="新建成功")
            {
                location.reload();
            }
        })
    }

    function showNewRoom_Modal() {
        jQuery("#newRoomModal").val();
        jQuery("#room_num").val();
        jQuery("#room_type").val();
        jQuery("#room_floor").val();
        jQuery("#newRoomModal").modal("show");
    }

    function doNewRoom() {
        jQuery("#newRoomModal").modal("hide");
        var id=jQuery("#newRoom_id").val();
        var num=jQuery("#newNum").val();
        var type=jQuery("#chooseType").val();
        var floor=jQuery("#newFloor").val();
        jQuery.post("/newRoom",{"num":num,"type":type,"floor":floor},function (rst) {
            alert(rst);
            if(rst=="新建成功")
            {
                location.reload();
            }
        })
        jQuery.post("/roomstatus_create",{"tableName":num},function(msg){
            if(msg!="添加成功")
            alert(msg);
        });
        jQuery.post("/roomBuy_create",{"tableName":num},function(msg){
            if(msg!="添加成功")
                alert(msg);
        });
    }

    function showEdit_roomType(id,type,type_price)
    {
        oldType=type;//把更改之前的类型名记录一下
        jQuery("#editRoomType_id").val(id);
        jQuery("#edit_roomType").val(type);
        jQuery("#edit_typePrice").val(type_price);
        jQuery("#editModal_roomType").modal("show");
    }

    function doEdit_roomType() {
        jQuery("#editModal_roomType").modal("hide");
        var id=jQuery("#editRoomType_id").val();
        var type=jQuery("#edit_roomType").val();
        var price=jQuery("#edit_typePrice").val();
        jQuery.post("/edit_roomType",{"id":id,"type":type,"price":price},function (rst) {
            /*alert(rst);*/
            if(rst=="修改成功")
            {
                location.reload();
            }
        })

        jQuery.post("/edit_type",{"new":type,"old":oldType},function (rst) {
            if(rst!="修改成功")
            {
                alert(rst);
            }
        })
    }

    function showDel_roomType(id,type)
    {
        jQuery("#delRoomType_id").val(id);
        jQuery("#delRoomType_msg").html(type);
        jQuery("#delModal_roomType").modal("show");
    }

    function doDelete_roomType(){
        jQuery("#delModal_roomType").modal("hide");
        var id = jQuery("#delRoomType_id").val();
        //json格式的属性名称必须和后台对应
        jQuery.post("/delete_roomType",{"id":id},function (rst) {
            alert(rst);
            //刷新页面,应重新加载一次
            if(rst=='删除成功')
            {
                //重新加载
                location.reload();
            }
        });
    }

    function showNewRoomType_Modal() {
        jQuery("#newRoomTypeModal").val();
        jQuery("#newRoomType").val();
        jQuery("#newTypePrice").val();
        jQuery("#newRoomTypeModal").modal("show");
    }

    function doNewRoomType() {
        jQuery("#newRoomTypeModal").modal("hide");
        var type=jQuery("#newRoomType").val();
        var price=jQuery("#newTypePrice").val();
        jQuery.post("/newRoomType",{"type":type,"type_price":price},function (rst) {
            alert(rst);
            if(rst=="新建成功")
            {
                location.reload();
            }
        })
    }

</script>
</html>
